package com.projectsexception.festivales.favorites.model;

import com.projectsexception.festivales.provider.model.Show;
import com.projectsexception.festivales.util.ShowComparator;

public class Favorite implements Comparable<Favorite> {
    
    private static final ShowComparator comparator = new ShowComparator();
    
    private int id;    
    private Show showInfo;
    
    public Favorite() {
        
    }
    
    public Favorite(Show showInfo) {
        this.showInfo = showInfo;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Show getShowInfo() {
        return showInfo;
    }

    public void setShowInfo(Show showInfo) {
        this.showInfo = showInfo;
    }

    @Override
    public int compareTo(Favorite favorite) {        
        return comparator.compare(this.showInfo, favorite.showInfo);
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + id;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Favorite fav = (Favorite) obj;
        if (id != 0 && id == fav.id)
            return true;
        return showInfo.getId() == fav.getShowInfo().getId();
    }

}
